
#include <algorithm>
#include <iterator>
#include <string>
#include <type_traits>
#include <vector>

class Solution {
 public:
  void foo(std::string &s, int beg, int end)
  {
    for (int i = beg, j = end - 1; i < j; ++i, --j) { std::swap(s[i], s[j]); }
  }

  std::string reverseStr(std::string s, int k)
  {
    for (int i = 0; i < s.size(); i += (2 * k))
    {
      if (i + k <= s.size())
      {
        foo(s, i, i + k);
      } else
      {
        foo(s, i, s.size());
      }
    }
    return s;
  }
};
